package itheima05;

import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;

/**
 * @author xxx
 * @date 2020/12/25 16:32
 * @description
 */
public class Test {
    public static void main(String[] args) {
        //1.Stream流方法forEach调用Consumer匿名函数接口
        Stream<String>stream=Stream.of("王大麻","小黄瓜","喝光黄啊","市购司","挖矿黄","黄鑫如","大光家","黄大二","马云","大黄狗","黄大拿","黄炳","黄大二","马小云","小黄狗");

        //2.Stream流方法filter调用Predicate匿名函数接口
        Stream<String>stream1=stream.filter(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.contains("黄");
            }
        });

        //数一下过滤后Stream还有多少个元素，过滤留下前3个之后剩下再跳过前两个
        Stream<String>stream2=stream1.limit(3);
        Stream<String>stream3=stream2.skip(2);
        //最后融合一个新的stream
        Stream<String>stream4=Stream.of("qq","11","222");

        Stream<String>stream5=Stream.concat(stream3,stream4);

        stream5.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });

    }
}
